import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import React from 'react';
import styles from "./styles.less?modules";
import SubMenuItem from "./SubMenuItem";
import { getMenuKey } from "./utils";

var SubMenu = /*#__PURE__*/function (_React$PureComponent) {
  _inherits(SubMenu, _React$PureComponent);

  var _super = _createSuper(SubMenu);

  function SubMenu() {
    _classCallCheck(this, SubMenu);

    return _super.apply(this, arguments);
  }

  _createClass(SubMenu, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          menu = _this$props.menu,
          activeMenus = _this$props.activeMenus,
          hoverSubMenu = _this$props.hoverSubMenu,
          getSubMenuItemStyle = _this$props.getSubMenuItemStyle,
          getSubMenuStyle = _this$props.getSubMenuStyle,
          minHeight = _this$props.minHeight,
          onClick = _this$props.onClick;
      return /*#__PURE__*/React.createElement("div", {
        className: [styles['sub-menu'], 'cpaas-sub-menu'].join(' '),
        style: _objectSpread(_objectSpread({}, getSubMenuStyle(menu)), {}, {
          minHeight: minHeight
        })
      }, menu.children.map(function (subMenu, index) {
        return /*#__PURE__*/React.createElement(SubMenuItem, {
          key: getMenuKey(subMenu),
          onClick: onClick,
          subMenu: subMenu,
          active: activeMenus[1] === subMenu,
          hover: hoverSubMenu === subMenu,
          style: getSubMenuItemStyle(subMenu, index >= menu.children.length - 1)
        });
      }));
    }
  }]);

  return SubMenu;
}(React.PureComponent);

export default SubMenu;